<template>
  <el-dialog title="条款" v-model="visible" width="60%" destroy-on-close>
    <el-form
      :model="form"
      ref="dialogForm"
      label-width="auto"
      label-position="right"
    >
      <el-form-item label="标题">
        <el-input
          v-model="form.articleTitle"
          clearable
          disabled
          placeholder="请输入条款标题"
        ></el-input>
      </el-form-item>
      <el-form-item label="内容" style="width: 100%">
        <sc-editor
          v-model="form.articleText"
          placeholder="请输入条款内容"
          :height="650"
          :toolbar="toolbar"
          :disabled="!$route.query.mode"
        ></sc-editor>
      </el-form-item>
    </el-form>

    <template #footer>
      <el-button @click="visible = false">取 消</el-button>
      <el-button type="primary" @click="save">保 存</el-button>
    </template>
  </el-dialog>
</template>
<script>
import { defineAsyncComponent } from 'vue'
const scEditor = defineAsyncComponent(() => import('@/components/scEditor'))
export default {
  name: '',
  data () {
    return {
      visible: false,
      isSaveing: false,
      //表单数据
      form: {
        articleTitle: '',//标题
        articleText: ''//内容
      },
      toolbar: [
        'undo redo |  forecolor backcolor bold italic underline strikethrough link | blocks fontfamily fontsize | \
					alignleft aligncenter alignright alignjustify | outdent indent | numlist bullist | pagebreak | \
					image  table  preview | selectall'
      ]
    }
  },
  components: {
    scEditor
  },
  methods: {
    open (data) {
      console.log(data)
      this.visible = true
      this.form = data
    },
    save () {
      console.log(this.form)
      this.$emit('saveClauseDetail', this.form)
      this.visible = false
    }
  }
}
</script>